package cn.afterturn.easypoi.freemarker;


import java.io.File;
import java.io.IOException;

import javax.servlet.ServletContext;

import freemarker.template.Configuration;  

public class FreemarkerConfiguration {  
    
  private static Configuration config = null;  
    
  /** 
   * Static initialization. 
   *  
   * Initialize the configuration of Freemarker. 
   */  
  static{  
      config = new Configuration();  
//      if(!new File("template").exists()){
//		  new File("template").mkdirs();
//	  }
	//  System.out.println(new File("template").getAbsolutePath());
	//config.setDirectoryForTemplateLoading(new File("template"));
	//config.setClassForTemplateLoading(clazz, pathPrefix);
	 // config.setClassForTemplateLoading(FreemarkerConfiguration.class, "/template");
  }
    
  public static Configuration getConfiguation(){
      return config;
  }
  
  public static void setConfiguation(ServletContext servletContext){  
	  config.setServletContextForTemplateLoading(servletContext, "/template");
  }
  public static Configuration getConfiguation(ServletContext servletContext){  
	  config.setServletContextForTemplateLoading(servletContext, "/template");
      return config;
  }
}  